package com.starblink.search.search.ui.cell

import com.starblink.android.basic.adapter.BaseBindingVH
import com.starblink.android.basic.sensorsdata.extension.trackData
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmElementDef
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmPageDef
import com.starblink.rocketreserver.fragment.SearchWordVOF
import com.starblink.rocketreserver.type.HotAndShadingWordVO
import com.starblink.search.databinding.CellSearchHotwordBinding

class SearchHotwordCell(binding: CellSearchHotwordBinding, val click: ((model: SearchWordVOF) -> Unit)? = null) :
    BaseBindingVH<SearchWordVOF, CellSearchHotwordBinding>(binding) {

    override fun onBind(model: SearchWordVOF, position: Int) {
        binding.btn.text = model.showWord

        // 埋点：点击Recently Viewed列表Item
        binding.btn.trackData(
            element = SpmElementDef.SearchRecommendBodyHotClick,
            page = SpmPageDef.SearchRecommendBody,
            onlyHit=true,
            params = mutableMapOf(
                "searchTerm" to model.showWord,
                "trendingWord" to model.showWord,
            )
        )
        binding.btn.setOnClickListener {
            click?.invoke(model)
        }
    }


}